<article>
  <h2 class="title"><?= CHtml::encode($data->name) ?></h2>
  <aside>
    <p><i class="fa fa-user"></i> 命题人: <span class="text-info"><?= CHtml::encode($data->user->name) ?></span> 老师
      <i class="fa fa-calendar"></i> 命题时间：<?= date('Y-m-d', $data->created_at) ?>
      <i class="fa fa-clock"></i> 测试时长：<?= $data->duration ?> 分钟</p>

    <p>共 <b class="label label-info"><?= count($data->questions) ?></b> 道题，每道 <b
          class="label label-info"><?= intval(100 / count($data->questions)) ?></b> 分</p>
  </aside>
</article>
<?php if (Yii::app()->user->getState('type') == 1): ?>
  <p id="tips">测试结束时间：<span id="clock"></span></p>
  <form id="exam-form" action="<?= Yii::app()->createUrl('bank/post') ?>" method="post">
    <?= CHtml::hiddenField('bank_id', $data->bank_id) ?>
    <?php foreach ($data->questions as $key=>$row): ?>
     <div class="question">
       <p><?=$key+1?>.<?=CHtml::encode($row->title)?></p>
       <?=CHtml::radioButtonList('question_'.$row->question_id,'A',array(
         'A'=>'A.'.$row->answer_a,
         'B'=>'B.'.$row->answer_b,
         'C'=>'C.'.$row->answer_c,
         'D'=>'D.'.$row->answer_d
       ))?>
     </div>
    <?php endforeach ?>
    <button type="submit" class="btn btn-success" onclick="return confirm('确定提交吗?')">完成答题</button>
  </form>
  <script src="/public/lib/scojs/js/sco.countdown.js"></script>
  <script>
    $(function () {
      initiCheck();
      $("#clock").scojs_countdown({
        until:<?=time()+$data->duration*60?>,
        callback: function () {
          $("#tips").html("时间到!系统将自动提交试卷!");
          $(".question").slideUp('slow');
          $("#exam-form").submit();
        }
      });
    });
  </script>
<?php else: ?>
<?php endif;